<template>
  <div>
    <el-menu
      :default-active="index"
      class="el-menu-vertical-demo"
      background-color="#545c64"
      text-color="#fff"
      active-text-color="#ffd04b"
      style="height: 910px;"
      @select="select"
    >
      <li class="exit" @click="exit">退出登录</li>
      <el-menu-item index="2">
        <i class="el-icon-menu"></i>
        <span slot="title">内容管理</span>
      </el-menu-item>
      <el-menu-item index="4">
        <i class="el-icon-document"></i>
        <span slot="title">用户管理</span>
      </el-menu-item>
      <el-menu-item index="3">
        <i class="el-icon-document"></i>
        <span slot="title">数据统计</span>
      </el-menu-item>
      <el-menu-item index="5">
        <i class="el-icon-document"></i>
        <span slot="title">举报反馈</span>
      </el-menu-item>
    </el-menu>
  </div>
</template>

<script>
export default {
  data() {
    return {
      index: 2
    };
  },
  methods: {
    select(index) {
      if (index == 2) {
        this.$router.push("/admin/art");
      } else if (index == 3) {
        this.$router.push("/admin/statstic");
      } else if (index == 4) {
        this.$router.push("/admin/user");
      }else if (index == 5) {
        this.$router.push("/admin/jubao");
      }
    },
    exit(){
      this.$store.commit("commons/setIsadmined",'0');
      this.$router.push("/admin")
    }
  },
  mounted() {
    let m = location.href;
    let l = m.split("/");
    let n = l[l.length - 1];
    if (n == "admin") {
      this.index = "2";
    } else if (n == "statstic") {
      this.index = "3";
    }
  }
};
</script>

<style>
.exit {
  display: block;
  height: 30px;
  line-height: 30px;
  color: white;
  font-size: 15px;
  border-radius: 50px;
  margin: 20px;
  background: cornflowerblue;
}
.exit:hover{
  background: rgb(14, 89, 228);
  cursor: pointer;
}
</style>